package com.gopay.common.cps.dao.wallet.prepaid.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Repository;

import com.gopay.common.base.dao.impl.BaseDAOImpl;
import com.gopay.common.cps.dao.wallet.prepaid.WaPrepaidOrderDtlDao;
import com.gopay.common.domain.dps.WaPrepaidOrderDtl;
import org.springframework.stereotype.Repository;

/**
 * 三充业务订单实现
 * @author LEI XIAOBAO
 * @date 2017年5月12日
 */
@Repository("waPrepaidOrderDtlDao")
public class WaPrepaidOrderDtlDaoImpl extends BaseDAOImpl<WaPrepaidOrderDtl, String> implements WaPrepaidOrderDtlDao{

	@Override
	public WaPrepaidOrderDtl queryByGopayOrderId(String gopayOrderId) {
		// TODO Auto-generated method stub
		String hql = " select m from WaPrepaidOrderDtl m where m.gopayOrderId = :gopayOrderId";
        Map<String, Object> params = new HashMap<String, Object>();
        params.put("gopayOrderId", gopayOrderId);
        
        List<WaPrepaidOrderDtl> waPrepaidOrderDtlList = findByHql(hql, params);
		if(waPrepaidOrderDtlList!=null && waPrepaidOrderDtlList.size()==1){
			return waPrepaidOrderDtlList.get(0);
		}
		return null;
	}
//    @Override
//    public Integer updateRechargeKey(String gopayOrderId,String rechargeKey) {
//        if (StringUtils.isNotEmpty(gopayOrderId)){
//            StringBuffer sb = new StringBuffer("");
//            sb.append("UPDATE WaPrepaidOrderDtl t set t.rechargeKey=:rechargeKey WHERE t.orderId=:gopayOrderId ");
//            Map<String, Object> map = new HashMap<String, Object>();
//            map.put("rechargeKey", rechargeKey);
//            map.put("gopayOrderId", gopayOrderId);
//            return updateByHql(sb.toString(), map);
//        }
//        return 0;
//    }
}
